﻿using Microsoft.Extensions.DependencyInjection;
using Oracle.ManagedDataAccess.Client;
namespace Gaea.Oracle
{
    public static class GaeaOracleExtension
    {
        public static IServiceCollection AddGaeaOracle(this IServiceCollection serviceCollection, string connectionString, string connectionName = "Oracle", MultipleConnectionType multipleConnectionType = MultipleConnectionType.Default)
        {
            serviceCollection.AddGaeaCore<OracleConnection>(new GaeaOracleAdapter());
            serviceCollection.AddGaeaOption(() =>
            {
                return new GaeaOption()
                {
                    ConnectionName = connectionName,
                    ConnectionString = connectionString,
                    GaeaNameSymbo = new string[] { "`" },
                    BaseTypeGaeaPower = typeof(GaeaOraclePower),
                    ConnectionType = multipleConnectionType,
                    TypeOfDbConnection = typeof(OracleConnection)
                };
            }).AddGaeaOption(() =>
            {
                return new GaeaOption()
                {
                    ConnectionName = connectionName,
                    ConnectionString = connectionString,
                    GaeaNameSymbo = new string[] { "`" },
                    BaseTypeGaeaPower = typeof(GaeaOraclePower<>),
                    ConnectionType = multipleConnectionType,
                    TypeOfDbConnection = typeof(OracleConnection)
                };
            });
            return serviceCollection;
        }
    }
}
